#ifndef SEARCH_H
#define SEARCH_H

#include "./include/define.h"
#include "./include/item.h"

#include <QtGui>

class QGroupBox;
class QPushButton;
class QGridLayout;
class QHBoxLayout;
class QVBoxLayout;

class Search : public QDialog
{
    Q_OBJECT

public:
    Search(QWidget *parent = 0);

protected:
    int count;
    bool isEmpty;  //是否查找到结果
    unsigned int pageSeq;  //页序号
    unsigned int maxPageSeq;  //最大的页序号
    unsigned int numOfTotalItem; //每次查询到的结果数量

    QGroupBox *groupBox;
    QPushButton *pageUp;
    QPushButton *pageDown;
    QGridLayout *bottomLayout;
    QHBoxLayout *topLayout;
    QVBoxLayout *mainLayout;

    int GetMaxPages();
    int GetNumOfTotalItem(const QString &sqlQuery);

    virtual QString BuildQuery() = 0;
    virtual void CreateWidget() = 0;
    virtual void CreateLayout() = 0;
    virtual void UpdateSearchResult(const QString &sqlQuery) = 0;

protected slots:
    void PageSeqInc();
    void PageSeqDes();
    virtual void SearchItems() = 0;
};

#endif // SEARCH_H
